# -*- encoding: utf-8 -*-
from shapely.wkt import loads as wkt_loads
import dsl
from . import FixtureTest


class NoNaturalPois(FixtureTest):

    def test_unnamed_natural_wood_hyde_park_london(self):
        # example from ticket: an unnamed natural=wood in Hyde Park, London
        # since this is unnamed, it might already get dropped as a POI, and
        # won't have a landuse label, so this checks for the polygon.
        self.generate_fixtures(dsl.way(186626491, wkt_loads('POLYGON ((-0.166511451569809 51.50746806996289, -0.166485041100456 51.50761360938839, -0.165148258126158 51.50751229655279, -0.165184190737523 51.50723256684208, -0.16521715890845 51.50692180373859, -0.165228747175615 51.5068151776226, -0.165857208548385 51.50683720737019, -0.165842027020083 51.50711487073789, -0.166511092243696 51.5071810713394, -0.166511451569809 51.50746806996289))'), {u'source': u'openstreetmap.org', u'way_area': u'15174.6', u'leisure': u'garden'}),dsl.way(157472697, wkt_loads('POLYGON ((-0.169174147903468 51.5082785671264, -0.168877793691237 51.50835236995989, -0.168804760658638 51.50823859054171, -0.168797214810251 51.50822701689457, -0.169093479190954 51.5081532138581, -0.16910219284921 51.50816680033511, -0.169174147903468 51.5082785671264))'), {u'name': u'Bird Sanctuary', u'way_area': u'857.824', u'leisure': u'garden', u'note': u'Dedicated to the memory of W.H. Hudson, writer and field naturalist', u'source': u'openstreetmap.org'}),dsl.way(-1756198, wkt_loads('POLYGON ((-0.170218349589728 51.507163570683, -0.170188076364654 51.5072802043237, -0.169965653500306 51.50740209342791, -0.170068151274224 51.5084991925139, -0.169767754643214 51.50899998469609, -0.169338539600462 51.50940058093271, -0.169102552175324 51.50946739322117, -0.169150791706081 51.50973117500651, -0.168845005183367 51.51002827712148, -0.168287151391928 51.51023530818001, -0.167911655603166 51.51024867040077, -0.167557629549695 51.51020187465669, -0.1667422287663 51.50992149054749, -0.166237914565795 51.50978786720438, -0.165969677621957 51.50977461666739, -0.165862418777033 51.51002156802478, -0.165615651568485 51.51027539483038, -0.165237909991513 51.50982191603489, -0.165089957464219 51.50970109568549, -0.164725151627338 51.50968778921369, -0.16417798778778 51.5095875991839, -0.164199457523071 51.5095541651852, -0.164231617210242 51.50950748054719, -0.164607112999004 51.50944066831751, -0.1647787810498 51.50934718694129, -0.164639362517704 51.50928708368239, -0.164995185201744 51.50878187771358, -0.16514646149559 51.50855281114288, -0.164307255357165 51.50800359460809, -0.164135138148728 51.50783138649249, -0.16449985415408 51.5077245947692, -0.164660832252995 51.5075843114392, -0.164435534779737 51.50756429489057, -0.164006319736985 51.50751089874719, -0.163995629785104 51.50738397782019, -0.164392505477628 51.50729720172291, -0.164660832252995 51.50727707322318, -0.16449985415408 51.50711688359549, -0.164497249039756 51.50695037524591, -0.16429908068808 51.5068368718919, -0.164242307162123 51.50657598084481, -0.164081418894738 51.50645576693628, -0.164242307162123 51.50630888188359, -0.164617892782414 51.50620868442329, -0.16449985415408 51.5061219060877, -0.164574953311833 51.50605508889328, -0.166001927140657 51.5060149985296, -0.166012617092538 51.50616859419479, -0.166334483458838 51.50619526510389, -0.166617093447222 51.5060727018034, -0.16669919946419 51.50632218934219, -0.1664203624 51.50636227943561, -0.16640958261659 51.5065025106147, -0.166602720402676 51.50658928822538, -0.16719075758766 51.50648858816039, -0.167289302774328 51.50654260054939, -0.167461060656652 51.50671621136608, -0.167628416794083 51.5067318111462, -0.1676755783465 51.50689988585777, -0.167638028767624 51.50699996997239, -0.167439501089833 51.50697659839438, -0.167321552293028 51.50707008463461, -0.167359101871904 51.50717698971728, -0.167224983399985 51.50730391122089, -0.167026545553723 51.50717698971728, -0.166790378465528 51.50722708741029, -0.166785078405352 51.50741400275859, -0.166860177563104 51.50762110160898, -0.167214203616576 51.5077679824315, -0.167777537131247 51.50783809591178, -0.167804306926714 51.5080250646652, -0.167632728707447 51.5081017753074, -0.167627338815743 51.50818200823878, -0.168056464026966 51.50812190344278, -0.168480199346486 51.50815528258119, -0.168539218660652 51.5081017753074, -0.168169112763595 51.5080617985676, -0.168158422811714 51.50796501557389, -0.168287151391928 51.50790820928427, -0.1684641195029 51.50796501557389, -0.168603627866524 51.50796501557389, -0.168646477505576 51.50792157218748, -0.168507148805009 51.50783468529048, -0.16863039766199 51.50778470008931, -0.1691401017542 51.5077346030094, -0.169220500972129 51.50767108698959, -0.169268830334414 51.50761769097139, -0.169059612704743 51.5076043838912, -0.168582247962762 51.5077245947692, -0.1684641195029 51.50764777166788, -0.168893334545652 51.50750418927979, -0.169097162283619 51.50746410019099, -0.16930637991329 51.5073906873053, -0.169349319383871 51.50729379106109, -0.169349319383871 51.5071369003406, -0.169338539600462 51.50702339745128, -0.169311679973467 51.50691990269828, -0.169531677386548 51.50664939504308, -0.169528443451525 51.50660807510899, -0.169714035389224 51.5065358909394, -0.169478047964086 51.506469074352, -0.169242060538947 51.50623541122279, -0.169113242127205 51.5061017770688, -0.169410853980833 51.50611111469809, -0.169724815172633 51.5063422064365, -0.170218349589728 51.507163570683), (-0.165895297116432 51.5082700686106, -0.165862328945504 51.50807007347599, -0.165791451869587 51.5080746023104, -0.165786511135525 51.50804441007259, -0.16576243628591 51.50789820108218, -0.165460782013503 51.5079172669848, -0.165463476959355 51.50793348138248, -0.165315614263589 51.50794287454809, -0.165319477019311 51.5079660778955, -0.16527312395065 51.5079689853021, -0.165285700364628 51.50804519283458, -0.165310044708828 51.50804357139898, -0.165339689113204 51.5082243890612, -0.165315434600533 51.50822601049028, -0.165328460172152 51.5083047895105, -0.165378137007364 51.50830160256908, -0.165382089594614 51.50832558849089, -0.165456110774026 51.5083208919478, -0.165452427681361 51.50829841562749, -0.165895297116432 51.5082700686106), (-0.166892427081804 51.5092737770898, -0.166774298621943 51.5091201918921, -0.166559780932095 51.50893317172218, -0.166495461557752 51.5087529159799, -0.166259384301085 51.5087529159799, -0.166259384301085 51.5089531876694, -0.165905358247614 51.50891986502608, -0.165787319619281 51.50901329136879, -0.165840949041742 51.50922698034428, -0.16608771625029 51.50914020775708, -0.166398802833181 51.50909346678479, -0.166602720402676 51.5091936019911, -0.166892427081804 51.5092737770898), (-0.166511451569809 51.50746806996289, -0.166511092243696 51.5071810713394, -0.165842027020083 51.50711487073789, -0.165857208548385 51.50683720737019, -0.165228747175615 51.5068151776226, -0.16521715890845 51.50692180373859, -0.165184190737523 51.50723256684208, -0.165148258126158 51.50751229655279, -0.166485041100456 51.50761360938839, -0.166511451569809 51.50746806996289), (-0.169174147903468 51.5082785671264, -0.16910219284921 51.50816680033511, -0.169093479190954 51.5081532138581, -0.168797214810251 51.50822701689457, -0.168804760658638 51.50823859054171, -0.168877793691237 51.50835236995989, -0.169174147903468 51.5082785671264))'), {u'source': u'openstreetmap.org', u'way_area': u'304204', u'natural': u'wood'}),dsl.way(-1756198, wkt_loads('POLYGON ((-0.169223555244095 51.50667366140109, -0.169134711862495 51.50686309510568, -0.168812845496195 51.50686650579979, -0.168678727024276 51.50691319314379, -0.168764516133909 51.5069833079395, -0.169038142969452 51.5069332099785, -0.169215200911952 51.50696658998768, -0.169183041224781 51.5071436098622, -0.168995203498871 51.5073371791336, -0.168684116915981 51.50745739071667, -0.168437349707433 51.5075675937079, -0.168217442125881 51.50749418098889, -0.168045684243557 51.50755758543099, -0.167847246397295 51.50729720172291, -0.16805116396679 51.5071535623174, -0.168281761500224 51.5070935120774, -0.168480199346486 51.50702339745128, -0.168426659755552 51.50693986361708, -0.168303231235514 51.50683636867438, -0.168179802715476 51.5067428819547, -0.168008224496209 51.50654260054939, -0.168201362282295 51.5065025106147, -0.168330001030981 51.50663608768009, -0.168544608552357 51.5067428819547, -0.168877254702066 51.50672957461889, -0.169223555244095 51.50667366140109))'), {u'source': u'openstreetmap.org', u'way_area': u'14971', u'natural': u'wood'}),dsl.way(-1756198, wkt_loads('POLYGON ((-0.167680878406676 51.50756770553218, -0.167616559032333 51.507687916507, -0.167450191041714 51.5076845058744, -0.167273222930743 51.5076110933439, -0.167214203616576 51.50749759163579, -0.167257143087157 51.50737067067168, -0.167396292124667 51.50731408729089, -0.16755223965799 51.50737067067168, -0.167680878406676 51.50756770553218))'), {u'source': u'openstreetmap.org', u'way_area': u'2426.37', u'natural': u'wood'}),dsl.way(-1756198, wkt_loads('POLYGON ((-0.168094013605843 51.50705677739439, -0.167911655603166 51.50711347292009, -0.167766757347838 51.50704011538231, -0.16780960698689 51.50691990269828, -0.167960883280736 51.50687589918538, -0.168077933762257 51.50691649200829, -0.168094013605843 51.50705677739439))'), {u'source': u'openstreetmap.org', u'way_area': u'1101.34', u'natural': u'wood'}))  # noqa

        self.assert_has_feature(
            16, 32737, 21792, 'landuse',
            {'id': -1756198, 'kind': 'natural_wood'})

        self.assert_no_matching_feature(
            16, 32737, 21792, 'pois',
            {'id': -1756198, 'kind': 'natural_wood'})

    def test_named_area_mt_cydonia_ponds(self):
        # named area, should get a label placement. note that we currently
        # only add landuse label placements at zoom 15+.
        # Mt. Cydonia Ponds Natural Area
        self.generate_fixtures(dsl.way(-6366946, wkt_loads('POLYGON ((-77.52718152499379 39.88861581267909, -77.5271813453308 39.88861629516857, -77.52706402535469 39.88898415792949, -77.5268943335975 39.88976199127517, -77.5268111496022 39.89006161156596, -77.5267540167501 39.8903273882111, -77.52667271921689 39.89054091859709, -77.52660247096169 39.8909277942611, -77.52655593823 39.8912048022362, -77.52655548907229 39.89120721459239, -77.5264245147039 39.89191878702638, -77.52629452848231 39.89186040858971, -77.51948089688379 39.89877690788839, -77.51510268785199 39.8961596027655, -77.51576923779288 39.89453735683978, -77.51565012118618 39.89446126789029, -77.516145991223 39.89325486079629, -77.5169639971207 39.89316278040629, -77.51681209200621 39.8921336909256, -77.5171433008514 39.89193712073999, -77.5178102101184 39.89151951061029, -77.51814114946899 39.89129991792869, -77.5189146887602 39.89079856024959, -77.5189218752825 39.89079401120792, -77.51911797750898 39.89066918814439, -77.52025677179471 39.8899391995695, -77.52058708232458 39.8897167758611, -77.5206228352729 39.88969278962318, -77.52067682402151 39.88965860232712, -77.52086214646459 39.88954129014521, -77.52097704098948 39.88947498317098, -77.5210065955623 39.88945940584748, -77.5210267178247 39.88944872228299, -77.5225072312444 39.88851738475839, -77.52258682197861 39.888465275802, -77.52349043732289 39.88790820376911, -77.52358359261788 39.88784899478279, -77.52361063190789 39.8878301085529, -77.52370486518119 39.88776379992348, -77.52381670543409 39.8876928041266, -77.52385694995878 39.88765641013608, -77.52401002288329 39.88752751459788, -77.5240995849171 39.88745086644111, -77.5241216834731 39.88743191117329, -77.5242081014034 39.88731742124409, -77.5242185218607 39.88730370449678, -77.52422534905681 39.88729481273461, -77.52427161229399 39.88723477607708, -77.52432928413521 39.8871415158148, -77.52438192541089 39.88700496822487, -77.5244140850981 39.88685346280679, -77.52442890730021 39.88668796446748, -77.52442782932189 39.8865430066184, -77.5244230682509 39.88592960336899, -77.52449610128349 39.88544020027889, -77.52455332396708 39.88522251817639, -77.52467522535109 39.88504777919308, -77.52488686843211 39.88484098692149, -77.5250399413565 39.88470091926861, -77.52523056385979 39.88453562252661, -77.52530674099589 39.8844755834528, -77.52567307396872 39.88417538729549, -77.52586010321089 39.88402470280459, -77.5259290938247 39.88396390503429, -77.52603859845779 39.88387918786988, -77.5260384187948 39.88388518493858, -77.52603383738681 39.88401546595859, -77.52602269827729 39.8843215909154, -77.52608935327139 39.8847291120426, -77.526096090636 39.88477088419989, -77.52613552667701 39.88501248668949, -77.52614792342789 39.88503585418899, -77.52625087035949 39.8852312723465, -77.5263117761358 39.8853796105548, -77.52653527697838 39.88592367540879, -77.5265356363046 39.8859249161447, -77.5265967217439 39.88614107956698, -77.5266466680737 39.88644030210808, -77.52666032246599 39.88669216913661, -77.5266699344395 39.88695616669819, -77.52667083275482 39.8870641090115, -77.5267549150654 39.88733968510439, -77.5267789000835 39.88745210714927, -77.52678644593189 39.88753089207768, -77.5267824035131 39.88770652079599, -77.5268074665095 39.8878123940917, -77.52685471789349 39.88791378691879, -77.52690008281529 39.88801118179109, -77.5270613304088 39.88835761140418, -77.5270614202403 39.88835768033148, -77.52718152499379 39.88861581267909))'), {u'source': u'openstreetmap.org', u'way_area': u'1.24277e+06', u'natural': u'wood', u'name': u'Mt. Cydonia Ponds Natural Area', u'DistrictNa': u'Michaux'}))  # noqa

        self.assert_has_feature(
            15, 9327, 12418, 'landuse',
            {'id': -6366946, 'kind': 'natural_wood',
             'label_placement': True})

        self.assert_no_matching_feature(
            15, 9327, 12418, 'pois',
            {'id': -6366946, 'kind': 'natural_wood'})

    def test_named_forest(self):
        # same, but for a forest
        # Liebesinsel, nr. Berlin, Germany
        self.generate_fixtures(dsl.way(316516905, wkt_loads('POLYGON ((13.356124604999 52.6467863730018, 13.3562024889341 52.6468825710583, 13.3563582568044 52.64693047924648, 13.3565764575869 52.64690671591968, 13.3566505685978 52.64690546234929, 13.356791873592 52.64677841553271, 13.3567657326173 52.64672156863931, 13.3567202778639 52.64665589212689, 13.3566345785858 52.64660520396279, 13.356513575517 52.64657697117489, 13.356350710956 52.6465916871091, 13.3562129093914 52.6466383965414, 13.3561505663107 52.64668178122039, 13.356124604999 52.6467863730018))'), {u'source': u'openstreetmap.org', u'way_area': u'3597.9', u'natural': u'forest', u'name': u'Liebesinsel'}))  # noqa

        self.assert_has_feature(
            16, 35199, 21454, 'landuse',
            {'id': 316516905, 'kind': 'natural_forest',
             'label_placement': True})

        self.assert_no_matching_feature(
            16, 35199, 21454, 'pois',
            {'id': 316516905, 'kind': 'natural_forest'})
